package com.yunheone.view.user;

import com.yunheone.Jdbc.JdbcHelp;
import com.yunheone.Jdbc.UserJdbc;
import com.yunheone.control.Usercontrol;
import com.yunheone.mode.User;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.function.BiConsumer;

/**
 * 展示用户列表
 */
public class UserList {

    public static int list(){

        System.out.println ("*********学员信息管理系统—账户管理*********");
        System.out.println ("编号\t\t用户名\t\t真实姓名\t\t用户类型");
        List<User> list = UserJdbc.chat ();
        list.forEach ( user -> System.out.println (user.getId ()+"\t\t\t"+user.getUseName ()+"\t\t\t"+user.getValName ()+"\t\t\t"+ user.getType ()));
        System.out.println ("1.增加用户    2.修改用户     3.删除用户     4.返回主页   5.刷新页面");
        Scanner input=new Scanner ( System.in );
        System.out.print ("请输入操作序号：");
        try{
            int i=input.nextInt ();
            if (i>5||i<1){
                throw new Exception("操作序号未识别");
            }
            return i;
        }catch (Exception e){
            String message = e.getMessage ();
            System.out.println (message!=null ? message : "输入不合法");
            return  list ();
        }
    }
}
